/*
 * Select.cpp
 *
 *  Created on: 03.12.2012
 *      Author: zheka
 */

#include "Select.hpp"
#include "Event.hpp"
#include "FileDescriptorSet.hpp"
#include <sys/select.h>
#include "util/ProxyException.hpp"

  void Select::select(const int maxFileDescriptor, Event & event) {
 		struct timeval tv;
 		tv.tv_sec = 1;
 		tv.tv_usec = 0;

		if (::select(maxFileDescriptor, event.getReadSet().getFileDescriptorSet(),
				event.getWriteSet().getFileDescriptorSet(), NULL, &tv) < 0) {
			throw ProxyException("Failed select system call");
		}
	}
